package handler.assetFormHandlers;

import javax.swing.JOptionPane;
import checker.AddAssetFormChecker;
import db.Asset;
import form.AssetForm.AssetForm;

public class AFAddButtonActionListener extends AbstractAFErrorCheckingButtonListener {
	
	public AFAddButtonActionListener(AssetForm assetForm){
		super(assetForm, new AddAssetFormChecker());
	
	}

	@Override
	public void performOperation() {
		if(Asset.insertNewAssetIntoDB(assetForm)){
			JOptionPane.showMessageDialog(null, "Successfully added "+assetForm.getAssetName().getInput()+".", "Success!", JOptionPane.INFORMATION_MESSAGE);
			assetForm.clear();
		}
		else
			JOptionPane.showMessageDialog(null, "Error in adding "+assetForm.getAssetName().getInput()+".", "Error!", JOptionPane.ERROR_MESSAGE);
	}
}
